package com.edge.pbx.view;

import android.content.Context;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class PbxViewParams {

    private static int sScreenWidth;
    private static int sScreenHeight;
    private static int sMunuButtonSize;


    public static void cal(Context context){
        WindowManager windowManager = null;
        int width = 0, height = 0;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            windowManager = context.getSystemService(WindowManager.class);
        }else{
            windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        }
        if (windowManager != null){
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
                Rect rect = windowManager.getCurrentWindowMetrics().getBounds();
                width = rect.width();
                height = rect.height();
            }else {
                DisplayMetrics displayMetrics = new DisplayMetrics();
                windowManager.getDefaultDisplay().getRealMetrics(displayMetrics);
                width = displayMetrics.widthPixels;
                height = displayMetrics.heightPixels;
            }
            if(width == 0 || height == 0){
                DisplayMetrics metrics = context.getResources().getDisplayMetrics();
                width = metrics.widthPixels;
                height = metrics.heightPixels;
            }
            sScreenWidth = Math.max(width, height);
            sScreenHeight = Math.min(width, height);
        }

        sMunuButtonSize = 282*sScreenWidth/3560;

    }

    public static int getScreenWidth() {
        return sScreenWidth;
    }

    public static int getScreenHeight() {
        return sScreenHeight;
    }
}
